﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace COFE.Core.Actions
{
    public interface IScriptParser
    {
        Tuple<object, string>[] ParseScript(Stream script);
        Stream GenerateScript(Tuple<object, string>[] commands);
    }

    public static class IScriptParserExtension
    {
        public static Tuple<object, string>[] ParseScript(this IScriptParser parser, string script)
        {
            return parser.ParseScript(new MemoryStream(Encoding.ASCII.GetBytes(script)));
        }

        public static string GenerateScript(this IScriptParser parser, Tuple<object, string>[] commands)
        {
            return new StreamReader(parser.GenerateScript(commands)).ReadToEnd();
        }
    }
}
